//
//  HomeLayout.swift
//  ----meilishuo
//
//  Created by wkywangking on 2017/3/2.
//  Copyright © 2017年 wkywangking. All rights reserved.
//

import UIKit

// 在storyboard中,把UICollectionView的layout绑定为此layout
class HomeLayout: UICollectionViewFlowLayout {
    
    /// 当cell要展示的时候,会调用此方法,对cell进行布局
    override func prepare() {
        super.prepare()
        
        // 1. 设置cell的尺寸
        let column: CGFloat = 3
        let margin: CGFloat = 10
        let width = (UIScreen.main.bounds.width - (column+1)*margin ) / column
    
        itemSize = CGSize(width: width, height: width)
        
        // 2.设置行列的间距
        minimumLineSpacing = margin
        minimumInteritemSpacing = margin
        
        // 3.设置内边距
        collectionView?.contentInset = UIEdgeInsetsMake(margin + 64, margin, margin, margin)
    
    
    }
    
    

}
